home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
ARGONET
/
PD
/
MATHS
/
RLAB
/
RLAB125.ZIP
/
!RLaB
/
help_ai
/
fvscope
< prev
next >
Wrap
Text File
|
1994-09-17
|
2KB
|
58 lines
fvscope:
Syntax: fvscope ( FNAME )
fvscope ( FNAME , FILE )
Description:
The fvscope function examines the compiled form of the
user-function, identified by FNAME, and prints a listing of
all the variables used within the function. Additionally the
scope of each variable is printed.
The second, and optional argument, is a string that denoted a
filename, or output process for fvscope to write it's output
to.
Fvscope is useful for writing general purpose functions that
will be used by others. It can be used to identify errant
global variables (variables that should be local, but were
overlooked).
Example:
> x = function ( y )
{
local (z)
z = 2*y + zz;
return z
}
<user-function>
> fvscope (x);
Function Variable SCOPE analysis for : x
Filename: stdin
line GLOBAL ARG LOCAL
1 Local-Var: z
1 Arg-Var: y
1 Global-Var: zz*
1 Local-Var: z
The above example shows a trivial user-function, and the
output from fvscope. Notice the typo on the 5th line of the
function (`z = 2*y + zz;'), which should have read: `z = 2*y +
z;'. Fvscope identifies the variable `zz' as a global
variable, signaling the function author (who did not want to
use any global variables) that there is a potential error.
Global variable references, to variables that are not
functions are flagged with an asterisk (`*') to help users
identify variables that are not class function.
Also note that the line numbers in the above example are all
1. In this particular case (the function is entered at the
command line) this behavior is correct. When running fvscope()
on a function that is stored in a file, the proper line
numbers will be reported.